<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <META HTTP-EQUIV="pragma" CONTENT="no-cache">
        <title>All issues</title>
        <!-- easy UI -->
        <link rel="stylesheet" type="text/css" href="<?=site_url("external/jquery-easyui/themes/default/easyui.css") ?>">
        <link rel="stylesheet" type="text/css" href="<?=site_url("external/jquery-easyui/themes/icon.css") ?>">
        <link rel="stylesheet" type="text/css" href="<?=site_url("external/jquery-easyui/demo/demo.css") ?>">
        <script type="text/javascript" src="<?=site_url("external/jquery-easyui/jquery.min.js") ?>"></script>
        <script type="text/javascript" src="<?=site_url("external/jquery-easyui/jquery.easyui.min.js") ?>"></script>
        <!-- end-->
        <link href="<?=site_url("css/main.css") ?>" rel="stylesheet" type="text/css" />
        <link href="<?=site_url("css/issue_view.css") ?>" rel="stylesheet" type="text/css" />
        <script src="<?=site_url("js/main.js") ?>" type="text/javascript"></script>
        <script type="text/javascript">
                        SITE_URL = "<?=site_url() ?>";
                        JIRA_ADDRESS = "<?=JIRA_ADDRESS?>";
        </script>
    </head>
    <body>
        
        <div id="right_click_menu" class="easyui-menu" style="width:120px;">
            <div data-options="iconCls:'icon-no'" onclick="javascript:remove_crash()">Remove</div>
            <div data-options="iconCls:'icon-redo'" onclick="javascript:goto_crash()">Goto</div>
        </div>
            <div>
                <p style="float: left">
                    <a href="<?=site_url("upload/CrashReporter.exe")?>">Download client</a><br><br>
                    
                    <a href="mailto:Bruce.Yu@garmin.com">Bug Report</a>
                </p>
                
                <p style="float: right"><a target="_blank" href="http://10.127.10.62:800/u/root">View Source</a></p>
            </div>
        <div id="issue_view">
            <div>
            <a href="<?=site_url()?>"><span style="font-size:25px;">Main Page</span></a>
            <a style="padding-right: 10px; float:right; color:red">Tip: Right click the crash</a>
            </div>
            <?if(!isset($view_mode) || $view_mode == VIEW_ALL):?>
                <div>
                <form action="<?=site_url("search_crash.php")?>" method="get" onsubmit="return searchCheck()">
                <select id="search_type" style="width:150px" name="type">
                    <option value="crash_report">crash report</option>
                    <option value="backtrace">backtrace</option>
                    <option value="variant">variant</option>
                    <option value="reporter">reporter</option>
                    <option value="jira" selected="true">jira</option>
                </select>
                <a id="search_content_container"><input name="content" type="text"></a>
                <span id="warning_input" style="color: red;display: none" >Please Input</span>
                <input type="submit" style="padding-left: 10px;padding-right: 10px" class="easyui-linkbutton" value="Search">
                <a href="<?=site_url("search_crash.php?type=variant&content=nuvi_")?>" style="padding-left: 10px;padding-right: 10px;float:right;margin-left: 20px" class="easyui-linkbutton">Capricorn</a>
                <a href="<?=site_url("search_crash.php?type=variant&content=astra_")?>"  style="padding-left: 10px;padding-right: 10px; float:right;" class="easyui-linkbutton">Alishan</a>
                </form>
                </div>
            <?endif//if($view_mode == VIEW_ALL):?>
            <?foreach($crash_reports as $crash):?>
            <div class="issue_title" <?if(isset($crash["highlight"]) && $crash["highlight"]) echo "style=\"background:#AACCFF\""?>crash_id="<?=$crash['id']?>">
                <p>
                    <span class="issue_contelt"><?=$crash['crash_title'] ?></span>
                </p>
            </div>
            <div class="issue_options">
                <p class="options">
                    <table>
                        <thead>
                            <tr>
                                <th>Crash time</th>
                                <th>SW build time</th>
                                <th>Process</th>
                                <th>Pid</th>
                                <th>Download log</th>
                                <th>View backtrace</th>
                                <th>Variant</th>
                                <th>SW Version</th>
                                <th>Reporter</th>
                                <th>JIRA</th>
                                <th>Repeat Times</th>
                            </tr>
                        </thead>
                        <tr>
                            <td><?=$crash['crash_time'] ?></td>
                            <td><?=$crash['build_time'] ?></td>
                            <td><?=$crash['process'] ?></td>
                            <td><?=$crash['pid'] ?></td>
                            <td><a href="<?=site_url("download_log.php?id=".$crash['id'])?>">Download</a></td>
                            <td>
                                <a href="javascript:void(0)" class="easyui-linkbutton">View</a>
                                <input id="backtrace_container" type="hidden" value="<?=$crash['backtrace'] ?>" />
                            </td>
                            <td><nobr><?=$crash['variant'] ?></nobr></td>
                            <td><nobr><?=$crash['sw_version'] ?></nobr></td>
                            <td><?=$crash['reporter'] ?></td>
                            <td>
                                <? if(!empty($crash['jira'])):?>
                                <a id="jira_display" href="<?=JIRA_ADDRESS.$crash['jira']?>" target="_blank"><?=$crash['jira']?></a>
                                <br><a class="jira">Modify</a></br>
                                <?else:?>
                                <a id="jira_display"><?=$crash['jira']?>None</a>
                                <br><a class="jira">Attach</a></br>
                                <?endif?>
                                <input type="text" crash_id="<?=$crash['id']?>" value="<?=$crash['jira']?>" class="jira"/>
                            </td>
                            <td><?=$crash['repeat'] ?></td>
                        </tr>
                    </table>
                </p>
            </div>
            <?endforeach ?>
        </div>
        <div id="backtrace_window" closed="true" class="easyui-window" title="BackTrace"
         style="width:1000px;height:500px;padding:10px;" maximized=true>
            <pre id="backtrace_shower">
            </pre>
        </div>
    </body>
    <script>
        <?if (isset($search_type)):?>
            switch ('<?=$search_type?>') {
                case 'crash_report':
                case 'backtrace':
                    input_text = '<textarea name="content" type="text"><?=$search_content?></textarea>';
                    break;
                default:
                    input_text = '<input name="content" type="text" value="<?=$search_content?>">';
                    break;
            }
            $container = $("#search_content_container");
            $container.html(input_text);
            $("#search_type").find("option[value='<?=$search_type?>']").attr("selected",true);
        <?else:?>
        $("#search_type").find("option[value='jira']").attr("selected",true);
        <?endif?>
        var $choosed_title = null;
        $(function(){
            $(".issue_title").bind('contextmenu',function(e){
                e.preventDefault();
                var id = $(this).attr('crash_id');
                $choosed_title = $(this);
                $('#right_click_menu').menu('show', {
                    left: e.pageX,
                    top: e.pageY
                });
                
            });
        });
        $(window).scroll(function(){//滚动时触发函数
           //$("#backtrace_window").css("top",$(document).scrollTop());//将滚动条高度赋给悬浮框。
           //$("#backtrace_window").panel('move', {top:100});
       })
        function remove_crash() {
            var r=confirm("确认删除?");
            if (r == false) {
                return false;
            }
            var crash_id = $choosed_title.attr('crash_id');
            var form_data = {
                id : crash_id,
            };
            $.ajax({
                url : SITE_URL + "remove_crash.php",
                type : 'post',
                data : form_data,
                success : function(msg, status) {
                    var text = "";
                    if (msg == "0") {
                        text = "Remove crash failed!";
                    } else {
                        text = "Remove crash Success!";
                        $choosed_title.toggle('fast');
                        if ($choosed_title.next(".issue_options").is(":hidden") == false) {
                            $choosed_title.next(".issue_options").toggle('fast');
                        }
                    }
                    $.messager.show({
                        title : 'Result',
                        msg : text,
                        timeout : 3000,
                        showType : 'slide'
                    });
                }
            });
        }
        function goto_crash() {
            var crash_id = $choosed_title.attr('crash_id');
            var url = SITE_URL + "view_crash.php?id=" + crash_id;
            window.open(url, '_blank')
        }
    </script>
</html>
